package com.mz.ozy.mvp.model;

import android.content.Context;
import android.text.TextUtils;

import com.mz.ozy.constants.Constants;
import com.mz.ozy.net.RetrofitUtils;
import com.mz.ozy.utils.JsonUtils;

import java.util.HashMap;
import java.util.Map;

import io.reactivex.Observable;
import okhttp3.ResponseBody;

public class PostDynamicModel {

    /**
     * 发表动态
     *
     * @param context
     * @param tid         tid
     * @param commentPics 图片集合
     * @param content     文字描述
     * @param reAddress   地址
     */
    public Observable<ResponseBody> onPostDynamic(Context context, String tid, String commentPics, String content, String reAddress) {
        Map<String, String> map = new HashMap<>();
        if (!TextUtils.isEmpty(tid)) {
            map.put("tid", tid);
        }
        if (!TextUtils.isEmpty(commentPics)) {
            map.put("commentPics", commentPics);
        }
        map.put("content", content);
        map.put("reAddress", reAddress);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10157, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }

    public Observable<ResponseBody> queryDynamicsDetail(Context context, String did) {
        Map<String, String> map = new HashMap<>();
        map.put("did", did);
        return RetrofitUtils.getApiService(context).post(Constants.TransCode.TransCode10164, JsonUtils.requestJsonDate(map), Constants.tokenId);
    }
}